import { createStore } from 'vuex'

export default createStore({
  state: {
    ExamplesPath: '',
    FiguresPath: '',
    theme: 'light',
    sysType: 'system',
    sysName: '系统仿真',
    locale: 'zh-CN',
    backupTime: 15,
    autoSave: true,
    serverIP: '114.112.124.182',
    serverPort: '8000',
    // serverIP: '127.0.0.1',
    // serverPort: '9000',
    defaultSaveRoot: '',
    saveRoot: '',
    libraryList: [],
    allLibraryList: [],
    coordinate: [0, 0],
    loadingTip: '加载中...',
    photGraph: {} as any,
    photGrid: {} as any,
    photActiveDevice: {} as any,
  },
  getters: {
  },
  mutations: {
    getExamplesPath(state, val) {
      state.ExamplesPath = val
    },
    getFiguresPath(state, val) {
      state.FiguresPath = val
    },
    getTheme(state, val) {
      state.theme = val
    },
    getSysType(state, val) {
      state.sysType = val
    },
    getSysName(state, val) {
      state.sysName = val
    },
    getDefaultSaveRoot(state, val) {
      state.defaultSaveRoot = val
    },
    getSaveRoot(state, val) {
      state.saveRoot = val
    },
    getLibraryList(state, val) {
      state.libraryList = val
    },
    getAllLibraryList(state, val) {
      state.allLibraryList = val
    },
    getCoordinate(state, val) {
      state.coordinate = val
    },
    getLoadingTip(state, val) {
      state.loadingTip = val
    },
    getPhotGraph(state, val) {
      state.photGraph = val
    },
    getPhotGrid(state, val) {
      state.photGrid = val
    },
    getPhotActiveDevice(state, val) {
      state.photActiveDevice = val
    },
  },
  actions: {
    setTheme(store, val) {
      store.commit('getTheme', val)
    },
    setExamplesPath(store, val) {
      store.commit('getExamplesPath', val)
    },
    setFiguresPath(store, val) {
      store.commit('getFiguresPath', val)
    },
    setSysType(store, val) {
      store.commit('getSysType', val)
    },
    setSysName(store, val) {
      store.commit('getSysName', val)
    },
    setDefaultSaveRoot(store, val) {
      store.commit('getDefaultSaveRoot', val)
    },
    setSaveRoot(store, val) {
      store.commit('getSaveRoot', val)
    },
    setLibraryList(store, val) {
      store.commit('getLibraryList', val)
    },
    setAllLibraryList(store, val) {
      store.commit('getAllLibraryList', val)
    },
    setCoordinate(store, val) {
      store.commit('getCoordinate', val)
    },
    setLoadingTip(store, val) {
      store.commit('getLoadingTip', val)
    },
    setPhotGraph(store, val) {
      store.commit('getPhotGraph', val)
    },
    setPhotGrid(store, val) {
      store.commit('getPhotGrid', val)
    },
    setPhotActiveDevice(store, val) {
      store.commit('getPhotActiveDevice', val)
    }
  }
})
